package edu.config;

import com.netflix.client.IClient;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by JPhoebe on 2017-7-8.
 */
@Configuration
public class RibbonConfig {

    @Autowired
    private IClientConfig iClientConfig;

    /**
     * ribbon默认是使用  轮训算法
     */
    @Bean
    public IRule ribbonRule(IClientConfig iClientConfig)
    {
        //随机
        return new RandomRule();
        //轮训
        //return new RoundRobinRule();
    }

}
